package com.hsnn.medstgmini.util;
import java.sql.Timestamp;

import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.hsnn.medstgmini.pro.plan.service.PricePlanManager;

/**
 * @category 字典工具类
 * @author 单大伟
 * @date 2015-06-12
 */
@Component
@Scope("singleton")
public class PriceAdjustUtil {
	
	private static final Logger log = Logger.getLogger(PriceAdjustUtil.class);

	
	public static void setPricePlanManager(PricePlanManager pricePlanManager) {
		PriceAdjustUtil.pricePlanManager = pricePlanManager;
	}

	private static PricePlanManager pricePlanManager;
	
	public static  void runPlan(){
		pricePlanManager.runChangePlanTask();
		Long time = DateUtil.parseDateHHTime(DateUtil.format(new Timestamp(System.currentTimeMillis()+1000 * 60 * 60), "yyyy-MM-dd HH")).getTime() - System.currentTimeMillis();
		log.info(Thread.currentThread().getName());
		try {
			Thread.sleep(time);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		while(true){
			pricePlanManager.runChangePlanTask();
			try {
				Thread.sleep(1000 * 60 * 60);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
	
}